<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Admin\Withdraw;

class WithdrawController extends Controller
{
    // 获取提现列表数据
    public function getList(Request $request)
    {
        $withdraws = new Withdraw;
        $result = $withdraws->getData($request);
        return $result;
    }

    //提现审核通过
    public function agree(Request $request)
    {   
        $id = $request->id;
        if(empty($id)){
            return $this->error(["info"=>"请选择提现申请"]);
        }
        $withdraws = new Withdraw;
        $result = $withdraws->agree($id);
        if($result == 1){
            return $this->success(["info"=>"操作成功"]);
        }
        return $this->error(["info"=>"操作失败"]);
    } 

    //提现审核拒绝
    public function refuse(Request $request)
    {
        $id = $request->id;
        $why = $request->data;
        if(empty($id)){
            return $this->error(["info"=>"请选择提现申请"]);
        }
        if(empty($why)){
            return $this->error(["info"=>"请输入拒绝理由"]);
        }
        $withdraws = new Withdraw;
        $result = $withdraws->refuse($id,$why);
        return $result;
    }

}